import esriLoader, { loadCss, loadModules } from "esri-loader";
class InitArcGisJs {
    static init = async () => {
        let moduleJsPath = [
            "esri/Map",
            "esri/views/MapView",
            "esri/views/SceneView",
            "esri/identity/IdentityManager",
            "esri/layers/TileLayer",
            "esri/layers/GraphicsLayer",
            "esri/layers/ElevationLayer",
            "esri/layers/GeoJSONLayer",
            "esri/layers/BaseElevationLayer",
            "esri/layers/FeatureLayer",
            "esri/layers/support/LabelClass",
            "esri/geometry/Polyline",
            "esri/geometry/Point",
            "esri/geometry/Extent",
            "esri/geometry/Circle",
            "esri/symbols/TextSymbol",
            "esri/symbols/ExtrudeSymbol3DLayer",
            "esri/symbols/SimpleFillSymbol",
            "esri/widgets/Legend",
            "esri/widgets/Expand",
            "esri/widgets/Home",
            "esri/Graphic",
            "esri/Camera",
            "dojo/on",
            "dojo/domReady!",
            "dojo/_base/lang",
            "esri/core/promiseUtils",
            "esri/rest/locator",
        ]
        let moduleNames = moduleJsPath.map(path => (path.match('[^/]+(?!.*/)')[0]));
        let options = {
            url: "https://js.arcgis.com/4.20/",
            css: "https://js.arcgis.com/4.20/esri/themes/light/main.css"
        };
        let arcgisModules = await loadModules(moduleJsPath, options);

        let modules = {};
        moduleNames.forEach((key, index) => {
            modules[key] = arcgisModules[index]
        });
        return modules
    }
}
export default InitArcGisJs